import Vue from 'vue'
import App from './App.vue'

//vant 引用
// import Vant from 'vant';
import 'vant/lib/index.css';

// Vue.use(Vant);

// 导入路由对应组件
import Find from '@/views/Find' // vue文件中，@表示 src目录的绝对路径
import My from '@/views/My'
import Part from '@/views/Part'
import NotFound from '@/views/NotFound'
import VueRouter from 'vue-router'

import Recommend from '@/views/Second/Recommend'

//注册插件
Vue.use(VueRouter)
//路由规划数组
const routes = [
	{
		path: '/find',
		component: Find
	},
	{
		path: '/my',
		component: My,
		children: [{

			path: 'recommend',
			component: Recommend


		}]


	},
	{
		path: '/part',
		component: Part
	},
	{
		path: '/part/:uname',
		component: Part
	},
	{
		path: '/',
		redirect: '/find'
	},
	{

		path: '*',
		component: NotFound
	}

]

import { Button } from 'vant';
Vue.use(Button);
//创建路由实例对象
const router = new VueRouter({
	routes,
	mode: 'history'// hash带#号，history不带
})
let login = false
router.beforeEach((to, from, next) => {
	if (to.path === '/my' && !login) {
		next(false)

	}
	else {


		next()
	}



})

Vue.config.productionTip = false

new Vue({
	router,
	render: (h) => h(App),
}).$mount('#app')



//步骤
//1.下包
//2.引入 vue-router
//3.注册 Vue.use()
//4.配置路由规则
//5.创建路由对象
//6.将路由注册到vue实例对象上
//7.使用 <router-view> </router-view> 挂载